package com.hy.study.reduce;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;
import java.util.HashSet;
import java.util.Set;

/**
 * @author huyong
 * @date 2024 年 02 月 07 日 15:32: 35
 */
public class TwoIndexReducer extends Reducer<Text, Text, Text, Text> {
    private final Text v = new Text();

    @Override
    protected void reduce(Text key, Iterable<Text> values, Reducer<Text, Text, Text, Text>.Context context) throws IOException, InterruptedException {
        StringBuilder builder = new StringBuilder();
        for (Text v : values) {
            String str = v.toString();
            builder.append(str.replace("\t", "-->")).append("\t");
        }
        v.set(builder.toString());
        context.write(key, v);
    }
}
